
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

// stores users first and last name without creating 100 functions? 

struct person{
    char first[100];
    char last[100];
    int marked;
};

// allows user to enter their first and last name 
struct person scan(int number){
    struct person man;
    
    printf("input first name\n");
    scanf("%s",man.first);
    printf("input last name\n");
    scanf("%s",man.last);
    man.marked = 0;
    
    return(man);
}

int main(int argc, const char * argv[])
{
    //creates list of 18 people
    struct person listofpeople[17];
    //creates random list of 18 people
    struct person randlistofpeople[17];
    //loops 18 times and stores user info into array  
    for(int i =0;i <= 17;i++){
        
        listofpeople[i] = scan();
        
        printf("%s %s has been marked for death. \n \n", listofpeople[i].first, listofpeople[i].last);
        
    }
    //loop for storing data into randlistofpeople
    for(int i = 0;i <= 17; i++){
        int test = rand() % 18; //Choosing random number from zero to 17 and sets it to test
        while(listofpeople[test].marked == 1){ //while number is already marked chose new random number 
            test = rand() % 18;
        }
        listofpeople[test].marked = 1; // If number wasn't marked, marks set person.
        randlistofpeople[i] = listofpeople[test]; //takes random number and saves it to random list of people
    }
    
    for(int i =0;i <= 17;i++){
        
        if (i == 17) {
            printf("%s %s's target is: %s %s \n", randlistofpeople[i].first, randlistofpeople[i].last, randlistofpeople[0].first, randlistofpeople[0].last);
        }else {
            printf("%s %s's target is: %s %s \n", randlistofpeople[i].first, randlistofpeople[i].last, randlistofpeople[i+1].first, randlistofpeople[i+1].last);
        }
    }

    return 0;
}
